package com.baizhi.controller;

import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public String login(User user, HttpSession session){
        user=userService.login(user);
        System.out.println(user);
        if (user!=null){
            session.setAttribute("user",user);
            return "redirect:selectAllAuction";
        }
        return "page/denglu";
    }
    @RequestMapping("/add")
    public String add(User user){
        userService.add(user);
        return "page/denglu";
    }
}
